package main

import (
	"fmt"
	"github.com/robfig/cron"
	"os"
	"os/signal"
	"syscall"
	"time"
)

func text() {
	print("test\n")
	fmt.Println("time:", time.Now().Format("2006/1/02 15:04:05"))
}

func main() {
	c := cron.New()
	// 秒 分 时 天 月 周
	err := c.AddFunc("* * * * * *",
		func() {
			text()
		})
	if err != nil {
		fmt.Println(err)
		return
	}

	c.Start()
	defer c.Stop()
	// select {}

	ch := make(chan os.Signal, 1)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGILL, syscall.SIGQUIT, syscall.SIGHUP, os.Interrupt)
	sig := <-ch
	print("Signal received: %v", sig.String())

}
